// 站点弹窗管理相关类型定义

// 站点信息
export interface Site {
    id: string
    name: string
    code: string
    domain: string
    status: 'active' | 'inactive'
    description?: string
}

// 优惠券信息
export interface Coupon {
    id: string
    name: string
    type: '满减券' | '折扣券' | '包邮券' | '无门槛券'
    value: number
    minAmount?: number
    status: 'draft' | 'published' | 'expired' | 'disabled'
    validStart: string
    validEnd: string
    description?: string
}

// 站点优惠券配置
export interface SiteCouponConfig {
    id: string
    siteId: string
    siteName: string
    couponId: string
    couponName: string
    popupRuleId?: string
    popupRuleName?: string
    status: 'active' | 'inactive'
    showFrequency: 'once' | 'every_visit' | 'daily' | 'weekly'
    userScope: 'all' | 'new_user' | 'vip_user' | 'specific_tags'
    userTags?: string[]
    createdAt: string
    updatedAt: string
}

// 弹窗规则
export interface PopupRule {
    id: string
    name: string
    description: string
    triggerType: 'immediate' | 'delay' | 'exit_intent'
    delaySeconds?: number
    popupTitle: string
    popupContent: string
    buttonText: string
    popupStyle: 'default' | 'coupon' | 'activity' | 'simple'
    showConditions: {
        userType: 'all' | 'new' | 'returning' | 'vip'
        deviceType: 'all' | 'desktop' | 'mobile'
        timeRange?: {
            start: string
            end: string
        }
        dayOfWeek?: number[]
    }
    frequencyLimit: {
        maxShows: number
        period: 'session' | 'day' | 'week' | 'month'
    }
    status: 'active' | 'inactive'
    createdAt: string
    updatedAt: string
}

// 弹窗样式
export interface PopupStyle {
    id: string
    name: string
    siteId: string
    siteName: string
    position: 'top_left' | 'top_center' | 'top_right' | 'center' | 'bottom_left' | 'bottom_center' | 'bottom_right'
    width: number
    height: number
    backgroundColor: string
    borderColor: string
    borderWidth: number
    borderRadius: number
    shadow: boolean
    animation: 'fade' | 'slide' | 'zoom' | 'bounce'
    animationDuration: number
    closeButton: {
        show: boolean
        position: 'top_right' | 'top_left' | 'bottom_right' | 'bottom_left'
        style: 'text' | 'icon' | 'image'
        text?: string
        icon?: string
        imageUrl?: string
    }
    customCSS?: string
    createdAt: string
    updatedAt: string
}

// 弹窗展示记录
export interface PopupRecord {
    id: string
    siteId: string
    siteName: string
    popupId: string
    popupName: string
    userId?: string
    userAgent: string
    ipAddress: string
    deviceType: 'desktop' | 'mobile'
    showTime: string
    closeTime?: string
    action: 'show' | 'close' | 'click' | 'convert'
    conversionData?: {
        orderId?: string
        amount?: number
        couponUsed?: string
    }
    createdAt: string
}

// 弹窗统计数据
export interface PopupStats {
    siteId: string
    siteName: string
    totalShows: number
    totalClicks: number
    totalConversions: number
    clickRate: number
    conversionRate: number
    avgShowTime: number
    revenue: number
    period: string
}

// 创建/编辑表单类型
export interface SiteCouponConfigForm {
    siteId: string
    couponId: string
    popupRuleId?: string
    status: 'active' | 'inactive'
    showFrequency: 'once' | 'every_visit' | 'daily' | 'weekly'
    userScope: 'all' | 'new_user' | 'vip_user' | 'specific_tags'
    userTags: string[]
}

export interface PopupRuleForm {
    name: string
    description: string
    triggerType: 'immediate' | 'delay' | 'exit_intent'
    delaySeconds?: number
    popupTitle: string
    popupContent: string
    buttonText: string
    popupStyle: 'default' | 'coupon' | 'activity' | 'simple'
    showConditions: {
        userType: 'all' | 'new' | 'returning' | 'vip'
        deviceType: 'all' | 'desktop' | 'mobile'
        timeRange?: {
            start: string
            end: string
        }
        dayOfWeek: number[]
    }
    frequencyLimit: {
        maxShows: number
        period: 'session' | 'day' | 'week' | 'month'
    }
    status: 'active' | 'inactive'
}

export interface PopupStyleForm {
    name: string
    siteId: string
    position: 'top_left' | 'top_center' | 'top_right' | 'center' | 'bottom_left' | 'bottom_center' | 'bottom_right'
    width: number
    height: number
    backgroundColor: string
    borderColor: string
    borderWidth: number
    borderRadius: number
    shadow: boolean
    animation: 'fade' | 'slide' | 'zoom' | 'bounce'
    animationDuration: number
    closeButton: {
        show: boolean
        position: 'top_right' | 'top_left' | 'bottom_right' | 'bottom_left'
        style: 'text' | 'icon' | 'image'
        text?: string
        icon?: string
        imageUrl?: string
    }
    customCSS?: string
}

// 搜索条件类型
export interface SiteCouponSearchForm {
    siteId?: string
    couponId?: string
    status?: 'active' | 'inactive'
    dateRange?: [string, string]
}

export interface PopupRuleSearchForm {
    triggerType?: string
    status?: 'active' | 'inactive'
    dateRange?: [string, string]
}

export interface PopupStyleSearchForm {
    siteId?: string
    position?: string
    animation?: string
    dateRange?: [string, string]
}

export interface PopupRecordSearchForm {
    siteId?: string
    popupId?: string
    action?: string
    deviceType?: string
    dateRange?: [string, string]
}
